package com.sino.cloud.api.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sino.cloud.api.domain.Swagger;
import com.sino.cloud.api.repo.SwaggerDocRepo;

/**
 * Project: zhcore
 *
 * @Comments
 * @Author Zhong Han
 * @Created Date 2017/4/5
 */
@RestController
@RequestMapping(path = "/swagger")
public class SwaggerPublish {

	@Autowired
	private SwaggerDocRepo swaggerDocRepo;

	@RequestMapping(path = "/", method = RequestMethod.GET)
	public String helloWorld() {
		return "Hello World!";
	}

	@RequestMapping(path = "/publish", method = RequestMethod.POST, consumes = "application/json;charset=utf-8")
	public void publish(@RequestBody Swagger swagger) {
		swaggerDocRepo.save(swagger);
	}
}
